-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce InflightProtocolDataQueue
#4834
Conversation
@mxinden Ready for review. Only has draft status because I want to adapt more protocols if we agree on the design. |
Adding |
ec2bbea
to
549a9d6
Compare
af9f93c
to
f600aa1
Compare
cc @dgarus You might enjoy this change :) |
This pull request has merge conflicts. Could you please resolve them @thomaseizinger? 🙏 |
@mxinden The last commit experiments with a |
async move { | ||
let stream = receiver | ||
.await | ||
.map_err(|_| io::Error::from(io::ErrorKind::BrokenPipe))? | ||
.map_err(into_reserve_error)?; | ||
|
||
let reservation = outbound_hop::make_reservation(stream).await?; | ||
|
||
Ok(reservation) | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an added benefit, the timeout of FuturesTupleSet
now also applies to the entire stream opening.
Description
This PR prototypes what I termed an
InflightProtocolDataQueue
. It is essentially a replacement forConnectionHandler::OutboundOpenInfo
, just slightly more generic. In essence, it allows users to submit a request to the queue, together with a piece of data and later submit responses.Internally, the responses are matched with a pending piece of data and later returned. Assuming the functions are called in the right order (which is an invariant that
libp2p-swarm
should uphold), this frees users from having to worry about tracking state separately.Resolves: #4510.
Related: #3268.
Notes & open questions
Opening this PR for early feedback. In a follow-up PR, I'd then deprecate
InboundOpenInfo
andOutboundOpenInfo
and point users towards the newlibp2p-protocol-utils
crate and theInflightProtocolDataQueue
.Change checklist